<%--
  Created by IntelliJ IDEA.
  User: 23867
  Date: 2020/10/1
  Time: 15:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>首页</title>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo"><h2>电力巡检系统</h2></div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <script type="text/javascript" src="js/jquery-3.4.1.js"></script>
            <script>
                setInterval("time.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
            </script>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item" id="time"><a href=""></a></li>
            <li class="layui-nav-item"><a href="#" id="wlecome"></a></li>
            <li class="layui-nav-item"><a href="#" id="role"></a></li>
            <li class="layui-nav-item" ><a href="javascript:;" id="exit">【退出】</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">我的工作平台</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="upcoming">待办列表</a></dd>
                        <dd><a href="javascript:;" id="userUpdate">个人资料修改</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item" id="system">
                    <a href="javascript:;">系统管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="roles">角色管理</a></dd>
                        <dd><a href="javascript:;" id="users">用户管理</a></dd>
                        <dd><a href="javascript:;" id="rolePermissions">角色权限配置</a></dd>
                        <dd><a href="javascript:;">系统配置</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item"><a href="javascript:;"  id="tower">杠杆管理</a></li>

                <li class="layui-nav-item"><a href="javascript:;"  id="line">线路管理</a></li>

                <li class="layui-nav-item" id="defect">
                    <a href="javascript:;">缺陷管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="defect_grade">缺陷类型设置</a></dd>
                        <dd><a href="javascript:;" id="defect_dengji">缺陷等级确认</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item" id="inspection">
                    <a href="javascript:;">巡检任务管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="inspection_task">巡检任务制定与分配</a></dd>
                        <dd><a href="javascript:;" id="inspectionyuan">巡检任务执行与回执</a></dd>
                        <dd><a href="javascript:;">缺陷查询</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item" id="eliminate">
                    <a href="javascript:;">消缺任务管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="eliminate_task">消缺任务制定与分配</a></dd>
                        <dd><a href="javascript:;" id="eliminate_yuan">消缺任务执行与回执</a></dd>
                        <dd><a href="javascript:;" id="sovlequery">消缺查询</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item">
                    <a href="javascript:;">信息统计</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" id="ins_tonji">巡检记录统计</a></dd>
                        <dd><a href="javascript:;" id="eliminate_tongji">消缺记录统计</a></dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;" id="content" ></div>
    </div>
    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com -
    </div>
</div>
<script  src="js/jquery-3.4.1.js"></script>
<script  src="js/index.js"></script>
<%--<script rel="stylesheet"  src="js/jquery.particleground.min.js"></script>--%>
<%--<script  src="layui/layui.all.js"></script>--%>
<script src="layui/layui.js"></script>
<%--<script rel="stylesheet" src="layui/lay/modules/laydate.js"></script>--%>
<script>
    //JavaScript代码区域
    layui.use(['element','form'], function(){
        var element = layui.element,
            form=layui.form;


        var user=JSON.parse(sessionStorage.getItem("users"));
        $("#exit").click(function () {
            $.ajax({
                url:"/exit.do",
                type:"post",
                dataType:"json",
                success:function (res) {
                    if (res.code == 200){
                        console.log(res)
                        layer.msg(res.msg,{icon:1,time:3000});
                        sessionStorage.setItem("users",null);
                        var second=2;
                        //定时器2秒后跳转
                        var interval = setInterval(function () {
                            second--;
                            if (second === -1) {
                                window.location.href="pages/login.html";
                                clearInterval(interval);
                            }
                        }, 1000);
                    }else if (res.code == 405){
                        layer.msg(res.msg,{icon:5});
                    }
                }
            });

        });
        if (user ==null) {
            alert("请先登录");
            window.location.href="pages/login.html"
        }else {
            $("#wlecome").text("欢迎："+user[0].user_name);
            $("#role").text("角色："+user[0].role_name);
        //线路管理
            if (user[0].role_id == 1) {
                $("#upcoming").hide();
            }
            else if (user[0].role_id == 2) {
            $("#upcoming").hide();
            $("#system").hide();
            $("#defect").hide();
            $("#inspectionyuan").hide();
            $("#eliminate_yuan").hide();
        }
        //巡检
       else if (user[0].role_id == 3){
            $("#system").hide();
            $("#eliminate").hide();
            $("#defect").hide();
            $("#tower").hide();
            $("#line").hide();
            $("#inspection_task").hide();
        }
        //消缺
        else if (user[0].role_id == 4){
            $("#system").hide();
            $("#inspection").hide();
            $("#defect").hide();
            $("#tower").hide();
            $("#line").hide();
            $("#eliminate_task").hide();
        }
        }
    });
</script>
</body>
</html>